package com.xn.myyxcampus.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;

public class ImageUtils {
	/**
	 * save bitmap to sd
	 * @param bitMap
	 * @param imagePath
	 */
	public static void putImageToSDcar(Bitmap bitMap, String imagePath) {
		if(bitMap == null && imagePath ==null || imagePath.equals("")||"".equals(imagePath)){
			return ;
		}
		File file = new File(imagePath);
		
		if(file.exists()){
			return ;
		}
		try {
			File parentFile = file.getParentFile();
			if(!parentFile.exists()){
				parentFile.mkdirs();
			}
			file.createNewFile();
			FileOutputStream os = new FileOutputStream(file);
			bitMap.compress(Bitmap.CompressFormat.PNG, 100, os);
			os.close();
		} catch (IOException e) {
			e.printStackTrace();
		}catch(OutOfMemoryError e){
			e.printStackTrace();
		}
	}
}
